package com.Controller;

import com.Service.ZLService;
import com.bean.ZL;
import com.bean.studentLogin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.List;

@Controller
public class ZLLoginIndexController {

    @Autowired
    private ZLService service;

    @RequestMapping("/ZLlogin")
    public String ZLlogin() {
        return "ZLindex";
    }

    @RequestMapping("/loginZL")
    public String LoginZL(studentLogin slogin) {
        /*
         * 判断登录的用户是否是助理，是助理，功能则跳转到助理页面
         * */
        List<ZL> zl = new ArrayList<>();
        zl = service.findAllzl();
        System.out.println(zl.size());
        for (int i = 0; i < zl.size(); i++) {
            /*
            用if判断用户提交的和数据库中学生的账号密码是否一直，不一致就返回错误页面，一致则允许学生进入添加信息页面
            * */
            if (slogin.getNumber() == zl.get(i).getId() && slogin.getPassword().
                    equals(zl.get(i).getPassword())) {
                return "zhuliTest";
            }
        }
        return "errorPage";
    }
}
